package cn.llssit.project.wechatapi.mapper;

import cn.llssit.project.wechatapi.domain.MovieSwiper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: Lesan
 * @Date: 2020-06-27
 */
public interface MovieSwiperMapper {
    @Select("SELECT * FROM movie_swiper")
    List<MovieSwiper> selectAll();

    @Select("SELECT * FROM movie_swiper WHERE active='1'")
    List<MovieSwiper> selectActive();

    @Select("SELECT * FROM movie_swiper WHERE active=#{active}")
    List<MovieSwiper> selectStatus(String active);

    @Select("SELECT * FROM movie_swiper WHERE type=#{type}")
    List<MovieSwiper> selectType(String type);

    @Select("SELECT * FROM movie_swiper WHERE id=#{id}")
    MovieSwiper selectById(int id);

    @Update("UPDATE movie_swiper SET type=#{type},url=#{url},active=#{active} WHERE id=#{id}")
    void updateItem(MovieSwiper swiper);

    @Insert("INSERT INTO movie_swiper VALUES(null,#{type},#{url},#{active})")
    void insertItem(MovieSwiper swiper);

    @Delete("DELETE FROM movie_swiper WHERE id=#{id}")
    void DeleteById(int id);
}
